import { onShow } from '@dcloudio/uni-app';
import dd from 'dingtalk-jsapi'; // 此方式为整体加载，也可按需进行加载
import { ref } from 'vue';

export function useTitle(headerTitle: string) {
  const title = ref(headerTitle);
  const setTitle = (_title: string) => {
    if (dd.version) {
      dd.biz.navigation.setTitle({
        title: _title,
      });
    }
  };

  onShow(() => {
    setTitle(title.value);
  });
  return { setTitle };
}
